python


import time

def bubble_sort(arr):
    n = len(arr)
    for i in range(n):
        swapped = False
        for j in range(0, n-i-1):
            if arr[j] > arr[j+1]:
                arr[j], arr[j+1] = arr[j+1], arr[j]
                swapped = True
        if not swapped:
            break


files = ['m1_sorted.txt', 'm2_reverse.txt', 'm3_shuffle.txt']
for file in files:
    with open(file, 'r') as f:
        values = [int(x) for x in f.read().split()]
        start_time = time.time()
        bubble_sort(values)
        end_time = time.time()
        duration_ms = (end_time - start_time) * 1000
        print(f"Время сортировки файла {file}: {duration_ms:.2f} миллисекунд")
